package action;

import controller.Action;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Curso;
import model.Professor;

public class ExcluirCursoAction extends ManterCursoAction {

    @Override
    public void setParametros(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        try {
            int codCurso = Integer.parseInt(request.getParameter("codCurso"));
            request.setAttribute("curso", Curso.obterCurso(codCurso));
            request.setAttribute("editar", "readonly");
            request.setAttribute("excluir", "readonly");
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

    @Override
    public void efetuaPersistencia(Curso curso) throws ServletException {
        try {
            curso.excluir();
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

}
